<HTML>
<HEAD>
  <TITLE>Ebean core API</TITLE>
</HEAD>
<Body BGCOLOR="#ffffff">
Core API (see <a href="Database.html">Database</a>, <a href="DB.html">DB</a> and <a href="Query.html">Query</a>).

<h3>Database</h3>
<p>
  Provides the main API for fetching and persisting beans. We can obtain the "default database"
  via <code>DB.getDefault()</code> or just use methods on DB.
</p>

<pre>{@code

// Example find by id

Order order = DB.find(Order.class, 10);


// Example save

Customer customer = DB.getReference(Customer.class, 42);

Order newOrder = new Order();
newOrder.setStatus(Order.Status.NEW);
newOrder.setCustomer(customer);
...

DB.save(newOrder);


// Example: Eagerly fetching associations

// fetch Customer 42 including their billing and shipping addresses
Customer customer = DB.find(Customer.class)
		.setId(42)
		.fetch("billingAddress")
		.fetch("shippingAddress")
		.findOne();

Address billAddr = customer.getBillingAddress();
Address shipAddr = customer.getShippingAddress();

}</pre>

</Body>
</HTML>
